import 'package:flutter/material.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/page/message_notice/message.dart';
import 'package:ytbusiness/page/message_notice/notify_home/notify_page/notify.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';

class MessageCenter extends StatefulWidget {
  @override
  _MessageCenterState createState() => _MessageCenterState();
}

class _MessageCenterState extends State<MessageCenter> {
  List<String> titleList = ["通知","消息"];
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length:titleList.length ,
      child: Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(
          elevation: 0.5,
          centerTitle: true,
          backgroundColor: Colors.white,
          title:TabBar(
            isScrollable: false,
            labelColor: YTTheme.theme,
            labelStyle: TextStyle(
                fontSize: setSp(18), fontWeight: FontWeight.w600),
            unselectedLabelColor: Color(0xff323232),
            unselectedLabelStyle: TextStyle(
                color: Colors.white, fontSize: setSp(15)),
            indicatorColor: YTTheme.theme,
            indicatorSize: TabBarIndicatorSize.label,
            tabs: titleList.asMap().map((key, value){
              return MapEntry(key, _tabItem(titleList[key]));
            }).values.toList(),
          ),
          leading: GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: (){
              Navigator.pop(context);
            },
            child: Row(
              children: [
                Container(
                    margin: EdgeInsets.only(left: setWidth(15)),
                    width: setWidth(10),
                    height: setWidth(17),
                    child: Image.asset("assets/images/return.png",fit: BoxFit.cover,)
                ),
              ],
            ),
          ),
          actions: [
            Container(
                margin: EdgeInsets.only(right: setWidth(15)),
                width: setWidth(10),
                height: setWidth(17),
            ),
          ],
        ),
        body: TabBarView(
          children: [
            Notify(),
            Message(),
          ],
        ),
      ),
    );
  }

  Widget _tabItem(String title) {
    return Tab(text: title);
  }
}
